/**
 * 
 * @Project le cOeur - Data Virtualization
 * @Date 08.12.2012
 * @Author Aebi Pascal, Kocher Marc
 * @School BFH-TI Biel, Bachelor Thesis
 *
 */

package main.framework.log;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 * The class LoggerCreator is used to create some java loggers.
 */
public class LoggerCreator {

	/**
	 * Creates a logger creator.
	 */
	public LoggerCreator() {}
	
	/**
	 * Creates a logger corresponding to the given parameters.
	 * 
	 * @param LoggerName The logger name.
	 * @param logLevel The log level.
	 * @param fileName The log file name.
	 * @return The created logger.
	 * @throws SecurityException If a security manager exists and if the caller does not have LoggingPermission("control").
	 * @throws IOException If there are IO problems opening the files.
	 */
	public Logger createLogger(String LoggerName, Level logLevel, String fileName) throws SecurityException, IOException {
		Logger logger = Logger.getLogger(LoggerName);
		logger.setLevel(logLevel);
		FileHandler txtFileHandler = new FileHandler(fileName, true);
	    SimpleFormatter txtSimpleFormatter = new SimpleFormatter();
	    txtFileHandler.setFormatter(txtSimpleFormatter);
	    logger.addHandler(txtFileHandler);
	    return logger;
	}

}
